package com.jy.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.pojo.Room;
import com.jy.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("room")
public class RoomController {
    @Autowired
    RoomService roomService;

    @RequestMapping("findPage")
    public Page findPage(Integer pn, Integer ps, String name) {
        return roomService.findPage(pn, ps, name);
    }

    @RequestMapping("deleteById")
    public boolean deleteById(Integer id) {
        roomService.removeById(id);
        return true;
    }

    @RequestMapping("upadd")
    public boolean deleteById(@RequestBody Room room) {
        roomService.saveOrUpdate(room);
        return true;
    }

    @RequestMapping("findAll")
    public List<Room> findAll() {
        return roomService.list();
    }
}
